home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Icon 8.1 / msm-2 / iconc.sit / tlex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-19  |  1.6 KB  |  57 lines  |  [TEXT/MPS ]

  1. /*
  2.  * Token table structure.
  3.  */
  4.  
  5. struct toktab {
  6.    char *t_word;        /* token */
  7.    int  t_type;            /* token type returned by yylex */
  8.    int  t_flags;        /* flags for semicolon insertion */
  9.    };
  10.  
  11. extern struct toktab toktab[];    /* token table */
  12. extern struct toktab *restab[];    /* reserved word index */
  13.  
  14. #define T_Ident        &toktab[0]
  15. #define T_Int        &toktab[1]
  16. #define T_Real        &toktab[2]
  17. #define T_String    &toktab[3]
  18. #define T_Cset        &toktab[4]
  19. #define T_Eof        &toktab[5]
  20.  
  21. /*
  22.  * t_flags values for token table.
  23.  */
  24.  
  25. #define Beginner 1        /* token can follow a semicolon */
  26. #define Ender    2        /* token can precede a semicolon */
  27.  
  28. /*
  29.  * optab contains token information along with pointers to implementation
  30.  *  information for each operator. Special symbols are also included.
  31.  */
  32. #define Unary  1
  33. #define Binary 2
  34.  
  35. struct optab {
  36.    struct toktab tok;        /* token information for the operator symbol */
  37.    int expected;         /* what is expected in data base: Unary/Binary */
  38.    struct implement *unary;  /* data base entry for unary version */
  39.    struct implement *binary; /* data base entry for binary version */
  40.    };
  41.  
  42. extern struct optab optab[]; /* operator table */
  43. extern int asgn_loc;         /* index in optab of assignment */
  44. extern int semicol_loc;      /* index in optab of semicolon */
  45. extern int plus_loc;         /* index in optab of addition */
  46. extern int minus_loc;        /* index in optab of subtraction */
  47.  
  48. /*
  49.  * Miscellaneous.
  50.  */
  51.  
  52. #define NextChar   nextchar()        /* macro to get next character */
  53. #define PushChar(c) peekc=(c)        /* macro to push back a character */
  54.  
  55. #define Comment '#'            /* comment beginner */
  56. #define Escape  '\\'            /* string literal escape character */
  57.